<?php

include('../../includes/classes/core.php');

mysql_close();

mysql_connect('192.168.11.254','root','Gl-1114') or die('no conect');
mysql_select_db('tsol') or die('no select base');

$action 	= $_REQUEST['act'];
$error		= '';
$data		= '';

switch ($action) {
	case 'get_list' :
		$count      = $_REQUEST['count'];
		$hidden     = $_REQUEST['hidden'];
		$start		= $_REQUEST['start'];
		$end		= $_REQUEST['end'];
	  	$rResult = mysql_query("SELECT  ad_logcalls.call_time,ad_logcalls.call_time,
                                        e.extension,
                                        ad_logcalls.number,
                                        SEC_TO_TIME(ad_logcalls.sec_talk_time),
                                        CONCAT('<p onclick=play1(', '\'', 'TSOLAD-',CONVERT(ad_logcalls.unique_id USING utf8),'.wav', '\'',  ')>მოსმენა</p>', '<a download=\"image.jpg\" href=\"http://212.72.155.175:8181/tsol/TSOLAD-', ad_logcalls.unique_id,'.wav', '\">ჩამოტვირთვა</a>') AS `file`
                                
                                FROM ad_logcalls 
                                JOIN ad_extensions AS e ON e.user_id=ad_logcalls.user_id 
                                WHERE  ad_logcalls.unique_id != '' 
                                AND ad_logcalls.sec_talk_time != 0 
                                AND DATE(ad_logcalls.call_time) BETWEEN '$start' AND '$end'");
	  	
		$data = array(
				"aaData"	=> array()
		);

		while ( $aRow = mysql_fetch_array( $rResult ) )
		{
			$row = array();
			for ( $i = 0 ; $i < $count ; $i++ )
			{
				/* General output */
				$row[] = $aRow[$i];
			}
			$data['aaData'][] = $row;
		}

		break;
		
	default:
		$error = 'Action is Null';
}

$data['error'] = $error;

echo json_encode($data);

?>

